<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<%@taglib uri="/WEB-INF/dianning.tld" prefix="dianning"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="zh-cn" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>设置置顶</title>
<link href="/css/infotop.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8"  src="/js/jquery-1.4.2.min.js"></script>
 <script>


var selectTime = 0;
var userAmount =0;
var reservepageAmount = 0;

$(	function(){
	selectTime = parseInt($("#reserve_FirstTimeLength").val());
	userAmount = parseInt($("#newUseramount").val());
	reservepageAmount = parseInt($("#reserve_PageAmount").val());
	$("#reserve_FirstTimeLength").val(selectTime);
	$("#reserve_setLength").html(selectTime*3);
	$("#reserve_UserAmount").html(userAmount);
	reserve_computeAmount();
	var frm = parent.$("#<s:property value="frm" escape="false"/>_<s:property value="id"/>");
	frm.css("height", "475px");
	}
)

//委托置顶选择地区
function reserve_selectPage(obj){
	var sConsume = parseInt(obj.value);
	if(obj.checked){
		reservepageAmount += sConsume;
	}else{
		reservepageAmount -= sConsume;
	}
	$("#reserve_PageAmount").val(reservepageAmount);
	//alert($("#realTime_PageAmount").val());
	reserve_computeAmount();
}

//委托置顶置顶小时变更
function reserve_hourChange(obj){
	var hour = obj.value;
	var minute = $("#startminute").val();
	$("#reserve_startTimehour").html(hour+":"+minute);
	
}

//委托置顶置顶分钟变更
function reserve_minuteChange(obj){
	var minute = obj.value;
	var hour = $("#starthour").val();
	$("#reserve_startTimehour").html(hour+":"+minute);

}

//委托置顶选择时间
function reserve_selectTime(obj){
	var timeLength = obj.value;
	timeLength = parseInt(timeLength);
	selectTime = timeLength;
	$("#reserve_FirstTimeLength").val(selectTime);
	$("#reserve_setLength").html(timeLength*3);
	reserve_computeAmount();
}

//委托置顶天数变更
function reserveDayChange(obj){
	var currDays=parseInt(obj.value);
    var date = new Date();
    date.setDate(date.getDate() + currDays);
    var year = date.getFullYear();
    var m = date.getMonth() + 1;
	var month = (m < 10) ? '0' + m : m;
	var d  = date.getDate();
	var day = (d < 10) ? '0' + d : d;
	var endtime = year+"-"+month+"-"+day;
	$("#reserve_endtime").html(endtime);
	reserve_computeAmount();
}

//计算委托所需金额
function reserve_computeAmount(){
	var amountCount = reservepageAmount * selectTime;
	var selectDay = parseInt($("#reserve_days").val());
	var allAmount = selectDay * reservepageAmount * selectTime;
	$("#reserve_dayAmount").html(amountCount);
	if (userAmount < allAmount) {
			$("#top_pay").css("display","none")
		    $("#reserve_Notop").css("display","");
    } else {
			$("#top_pay").css("display","");
		    $("#reserve_Notop").css("display","none");
   }
}
</script>
</head>

<body>

	<div class="mbottom">
		<div class="newzd"> 
			<div class="zdbody">
			<!-- 置顶主体开始 -->
				<div class="zdtit">
					<ul>
						<li><span><a href="info.action?action=refresh&frm=<s:property value="frm" escape="false"/>&id=<s:property value="id"/>">刷新</a></span></li>
						<li><span><a href="info.action?action=autorefresh&frm=<s:property value="frm" escape="false"/>&id=<s:property value="id"/>">定时刷新</a></span></li>
						<li><span><a href="info.action?action=top&frm=<s:property value="frm" escape="false"/>&id=<s:property value="id"/>">置顶</a></span></li>
						<li class="select"><span><a href="info.action?action=autotop&frm=<s:property value="frm" escape="false"/>&id=<s:property value="id"/>">委托置顶</a></span></li>
					</ul>
				</div>
				<div class="clear"></div>
				
				<div class="zdinfo">
					<s:if test="message=='true'">
						<div class="yellow-b">置顶成功</div>
					</s:if>
					<s:if test="reserves != null">
					<div class="yellow-b">您己经委托置顶该信息</div>
					</s:if>
					<s:else>
					<div class="tjzd">
						<table border="0" cellpadding="0" cellspacing="0" class="tjzdtable">
						<form name="free" id="free" method="post" action="info.action">
						<input name="action" id="action" type="hidden" value="doautotop" />
						<input name="id" id="id" type="hidden" value="<s:property value="id"/>" />
						<input type="hidden" id="newUseramount" value="<s:property value="money.points"/>"/>
								<tr><td width="200" class="tdwt"> 选择委托页面：</td>
									<td>
									<p><input name="reserve_checkpage" checked="checked" type="checkbox" onclick="reserve_selectPage(this)" value="10"/><dianning:webinfo type="area"/>-<s:property value="info.smallChannel.channelName"/></p>
									<s:if test="area!=null">
									<p><input name="reserve_checkpage" checked="checked" type="checkbox" onclick="reserve_selectPage(this)" value="1"/><s:property value="info.area.areaname"/>-<s:property value="info.smallChannel.channelName"/></p>
									</s:if>
									<s:if test="area==null">
										<input type="hidden" id="reserve_PageAmount" value="10"/>
									</s:if>
									<s:else>
										<input type="hidden" id="reserve_PageAmount" value="11"/>
									</s:else>
									</td>
								</tr>
								<tr><td class="tdwt"> 委托开始时间：</td>
									<td> 明日
									<select id="starthour" name="starthour" onchange="reserve_hourChange(this)">
											<option value="00">0</option>
											<option value="01">1</option>
											<option value="02">2</option>
											<option value="03">3</option>
											<option value="04">4</option>
											<option value="05">5</option>
											<option value="06">6</option>
											<option value="07">7</option>
											<option value="08" selected="selected">8</option>
											<option value="09">9</option>
											<option value="10">10</option>
											<option value="11">11</option>
											<option value="12">12</option>
											<option value="13">13</option>
											<option value="14">14</option>
											<option value="15">15</option>
											<option value="16">16</option>
											<option value="17">17</option>
											<option value="18">18</option>
											<option value="19">19</option>
											<option value="20">20</option>
											<option value="21">21</option>
											<option value="22">22</option>
											<option value="23">23</option>
									</select> 时 &nbsp;
									<select id="startminute" name="startminute" onchange="reserve_minuteChange(this)">
									<option value="00">0</option>
									<option value="05">5</option>
									<option value="10">10</option>
									<option value="15">15</option>
									<option value="20">20</option>
									<option value="25">25</option>
									<option value="30">30</option>
									<option value="35">35</option>
									<option value="40">40</option>
									<option value="45">45</option>
									<option value="50">50</option>
									<option value="55">55</option>
									</select>分 开始置顶
									</td>
								</tr>
								<tr><td class="tdwt">每天置顶时长： </td>
									<td>
									<input name="timelength" onclick="reserve_selectTime(this)" id="timelength1" type="radio" value="1" />3小时
									<input name="timelength" onclick="reserve_selectTime(this)" id="timelength2" type="radio" value="2" checked />6小时
									<input name="timelength" onclick="reserve_selectTime(this)" id="timelength3" type="radio" value="4" />12小时
									<input name="timelength" onclick="reserve_selectTime(this)" id="timelength4" type="radio" value="5" />15小时
									<input name="timelength" onclick="reserve_selectTime(this)" id="timelength5" type="radio" value="6" />18小时
									<input type="hidden" id="reserve_FirstTimeLength" value="2"/>
									</td>
								</tr>
								<tr><td class="tdwt">委托持续天数： </td>
									<td>
									<select id="reserve_days" name="reserve_days" onchange="reserveDayChange(this)">
										<option value="1" selected = "selected">1</option>
										<option value="3" >3</option>
										<option value="10" >10</option>
										<option value="20" >20</option>
										<option value="30" >30</option>
									</select>&nbsp;天
									<span class="gray mr10">您选择的置顶时间为<b class="red">
									<s:date name="tomorrow" format="yyyy-MM-dd"/>
									</b>至<b class="red" id="reserve_endtime">
									<s:date name="tomorrow" format="yyyy-MM-dd"/>
									</b>每日<b class="red" id="reserve_startTimehour">08:00</b>起置顶<b class="red" id="reserve_setLength">6</b>小时</span>
									</td>
								</tr>
								<tr id="reserve_textArea">
									<td colspan="2">
									<div class="yellow-b">
									<span class="hfsj">此次委托预计<span class="red">每天</span>花费<span class="red" id="reserve_dayAmount"></span>积分，您可用余额为<span class="red" id="reserve_UserAmount"></span>积分。
									<span id="reserve_Notop" class="red">余额不足</span>
									</span>
									</div>
									</td>
								</tr>
								<tr><td class="tdwt">&nbsp;</td>
									<td><span class="tyzdbut"  id="top_pay">
									<label class="butt">
										  <input name="" type="submit" value="委托置顶" class="btns" />
										  </label>
									</span></td>
								</tr>
								</form>
								</table>
					</div>
				</s:else>	
			</div>
		</div>
	</div>
	
</body>
</html>